package com.business.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.business.system.mapper.AudtmsgMapper;
import com.business.system.service.IAudtmsgService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.business.system.vo.AllAuditMsg;
import com.common.entity.Audtmsg;
import com.common.untils.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pgx
 * @since 2022-09-05
 */
@Service
public class AudtmsgServiceImpl implements IAudtmsgService{
    @Autowired
    private AudtmsgMapper audtmsgMapper;
    @Override
    public CommonResult findAllAuditMsg(AllAuditMsg auditMsg) {
        Page<Audtmsg> page = new Page<>(auditMsg.getCurrentPage(),auditMsg.getPageSize());
        QueryWrapper<Audtmsg> queryWrapper = new QueryWrapper<>();
        if(StringUtils.hasText(auditMsg.getUsername())){
            queryWrapper.like("username",auditMsg.getUsername());
        }
        if(StringUtils.hasText(auditMsg.getSname())){
            queryWrapper.like("s_name",auditMsg.getSname());
        }
        if(StringUtils.hasText(auditMsg.getBeginTime())){
            queryWrapper.ge("audttime",auditMsg.getBeginTime());
        }
        if(StringUtils.hasText(auditMsg.getEndTime())){
            queryWrapper.le("audttime",auditMsg.getEndTime());
        }
        queryWrapper.eq("is_deleted",0);
        queryWrapper.ne("u_name","");
        Page<Audtmsg> pageAudtmsg =  audtmsgMapper.selectPage(page,queryWrapper);
        if(pageAudtmsg!=null){
            return new CommonResult(2000,"查询成功",pageAudtmsg);
        }else {
            return new CommonResult(5000,"查询失败",null);
        }
    }
}
